package com.kingdee.eas.custom.hr.attendance.app;

import java.util.Iterator;
import java.util.Set;

import org.apache.log4j.Logger;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.custom.hr.attendance.AccessDataEffectConfigCollection;
import com.kingdee.eas.custom.hr.attendance.AccessDataEffectConfigInfo;
import com.kingdee.eas.framework.CoreBaseCollection;

public class AccessDataEffectConfigControllerBean extends
		AbstractAccessDataEffectConfigControllerBean {
	private static Logger logger = Logger
			.getLogger("com.kingdee.eas.custom.hr.attendance.app.AccessDataEffectConfigControllerBean");

	@Override
	public void saveAccessDataEffectConfig(Context ctx,
			AccessDataEffectConfigInfo configInfo) throws BOSException,
			EASBizException {
		super.saveAccessDataEffectConfig(ctx, configInfo);
		Set addSet = (Set) configInfo.get("addSet");
		Set updateSet = (Set) configInfo.get("updateSet");
		Set deleteSet = (Set) configInfo.get("deleteSet");

		Iterator it = addSet.iterator();
		AccessDataEffectConfigInfo info = null;

		AccessDataEffectConfigCollection colls = new AccessDataEffectConfigCollection();
		while (it.hasNext()) {
			info = (AccessDataEffectConfigInfo) it.next();
			colls.add(info);
		}
		this._saveBatchData(ctx, colls);

		IObjectPK[] pks = new ObjectUuidPK[deleteSet.size()];
		int i = 0;
		it = deleteSet.iterator();
		while (it.hasNext()) {
			info = (AccessDataEffectConfigInfo) it.next();
			pks[i++] = new ObjectUuidPK(info.getId());
		}
		this.deleteBatchData(ctx, pks);

		 CoreBaseCollection collection = new CoreBaseCollection();
		it = updateSet.iterator();
		while (it.hasNext()) {
			info = (AccessDataEffectConfigInfo) it.next();
			 collection.add(info);
//			this.update(ctx, new ObjectUuidPK(info.getId()), info);
		}

		 this.updateBatchData(ctx, collection);
	}
}